﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace KP_CommonLibrary.KP_ObjectReferences
{
    #region KP_OCnnSql
    public class KP_OCnnSql
    {
        static string _server_name = "Design-Unknown";
        static string _server_user;
        static string _server_pass;
        static string _server_dbname = "Design-Unknown";
        static string _cnn_string;

        #region Properties
        public static string Server_Name
        {
            get { return _server_name; }
            set { _server_name = value; }
        }
        public static string Server_User
        {
            get { return _server_user; }
            set { _server_user = value; }
        }
        public static string Server_Pass
        {
            get { return _server_pass; }
            set { _server_pass = value; }
        }
        public static string Server_DbName
        {
            get { return _server_dbname; }
            set { _server_dbname = value; }
        }
        public static string Cnn_String
        {
            get { return _cnn_string; }
        }
        #endregion

        #region Methods
        public static void Gen_CnnString()
        {
            // _cnn_string = "Server=" + _server_name + ";DataBase=" + _server_dbname + ";uid=" + _server_user + ";pwd=" + _server_pass + ";";
            SqlConnectionStringBuilder connectionBuilder = new SqlConnectionStringBuilder();

            connectionBuilder.PersistSecurityInfo = true;
            connectionBuilder.Password = _server_pass;
            connectionBuilder.UserID = _server_user;
            connectionBuilder.DataSource = _server_name;
            connectionBuilder.InitialCatalog = _server_dbname;
            //   connectionBuilder.ConnectTimeout = 30 * 1000;
            _cnn_string = connectionBuilder.ConnectionString;
            connectionBuilder = null;
        }
        #endregion
    }
    #endregion
}
